<template>
  <div>
    <div v-for="order in orderList">
      <div style="width: 800px; height: 200px; border: 1px solid #DDD">
        <el-container>
          <el-header style="text-align: left; line-height: 60px; background-color: #EEE">
            <span style="font-size: 15px">
              {{order.orderTime | formatDate}}
            </span>
            <span style="font-size: 12px; margin-left: 20px; color: #BBB">
              凤眼订单号：{{order.orderNumber}}
            </span>
          </el-header>
          <el-main style="text-align: left;">
            <el-container>
              <el-aside>
                <el-container>
                  <el-aside style="width: 110px">
                    <el-image
                        style="width: 80px; height: 80px"
                        :src="order.moviePic"
                        fit="fill"></el-image>
                  </el-aside>
                  <el-main style="text-align: left;">
                    <div><h3>《{{order.movieName}}》</h3></div>
                    <div><span style="font-size: 14px; color: #BBB">{{order.cinemaName}}</span></div>
                    <div><span style="font-size: 14px; color: #BBB">{{order.lobbyName}}</span></div>
                    <div><span style="font-size: 14px; color: red">{{order.startTime | formatDateTime}}</span></div>
                  </el-main>
                </el-container>
              </el-aside>
              <el-main style="text-align: center">
                <el-container>
                  <el-aside style="width: 250px">
                    <div>
                      <span style="line-height: 70px">
                        ￥{{order.money}}
                      </span>
                    </div>
                  </el-aside>
                  <el-main style="text-align: right;">
                    <el-button @click="handleOrderDetails(order.orderNumber)">
                      查看详情
                    </el-button>
                  </el-main>
                </el-container>
              </el-main>
            </el-container>
          </el-main>
        </el-container>
      </div>
      <el-divider></el-divider>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import {formatDate} from "@/components/date";
Vue.filter('formatDate', function (time){
  let date = new Date(time)
  return formatDate(date,'yyyy-MM-dd')
})
Vue.filter('formatDateTime', function (time){
  let date = new Date(time)
  return formatDate(date,'MM月dd日 hh:mm')
})
export default {
  name: "UserOrderView",
  data() {
    return {
      orderList: []
    }
  },
  created() {
    this.handleGetUserOrderList()
  },
  methods: {
    handleGetUserOrderList() {
      this.axios.get("/web/order/list").then(response => {
        this.orderList = response.data.data
      })
    },
    handleOrderDetails(orderNumber){
      this.$router.push({path:"/webMenu/userOrderDetails", query: {
        orderNumber: orderNumber
      }})
    }
  }
}
</script>

<style scoped>

</style>